package com.janus.multitypedemo.vb;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.janus.multitypedemo.R;
import com.janus.multitypedemo.bean.Banner;

import me.drakeet.multitype.ItemViewBinder;

/**
 * Created by janus on 2017/7/10.
 * BannerViewBinder
 */

public class BannerViewBinder extends ItemViewBinder<Banner, BannerViewBinder.BannerHolder> {

    @NonNull
    @Override
    protected BannerHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View view = inflater.inflate(R.layout.layout_banner, parent, false);
        return new BannerHolder(view);
    }

    @Override
    protected void onBindViewHolder(@NonNull BannerHolder holder, @NonNull Banner item) {
        Glide.with(holder.imageView.getContext())
                .load(item.url)
                .into(holder.imageView);
        Log.d("sv-", "onbindvh-banner");
    }

    static class BannerHolder extends RecyclerView.ViewHolder {

        ImageView imageView;

        BannerHolder(View itemView) {
            super(itemView);
            imageView = (ImageView) itemView.findViewById(R.id.iv_banner);
        }

    }
}
